﻿//---------------------------------------------------------------------------


#pragma hdrstop

#include "stdafx.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

/*
程式構想
---------------------------
MELODY：用演算法去學，快樂悲傷軸決定樂器，激昂冷靜決定密集度
TEMPO：用FUZZY去調整
PAD：按照每個點（ex: sad happy）來決定要用哪一個pad，模糊地帶則用Membership function決定
BASS：快樂悲傷軸決定節奏類型，激昂冷靜決定要密集還是鬆散（一個小節只能更改一次）
DRUM：快樂悲傷軸決定節奏類型，激昂冷靜決定要密集還是鬆散（一個小節只能更改一次）
電木吉他：冷靜比較偏木吉他，激昂比較篇電吉他（中間有重疊地帶，用音量去調整比例多寡），快樂悲傷軸決定節奏類型。

//////consider the harmony of tones by dealing with the different conditions
//////of chord notes, which can efficiently exclude the disharmonious noise.
1 The rhythm of chord notes 4410 -87
？？？
2 The note is a chord note 13300 44
這個音在和弦裡面
3 The note is a chord note (chord root note) 284 504
這個音在和弦（第1個音）裡面
4 The note is a chord note (chord 2nd note) 223 234
這個音在和弦（第2個音）裡面
5 The note is a chord note (chord 3rd note) 304 95
這個音在和弦（第3個音）裡面
6 The note of phrase cadence is the chord note 331 846   phrases 一小段樂句  Cadence : 終止式
終止式的小節裡（4,8,12...小節） 的音是和弦音
7 The note of phrase cadence is not the chord note 1397 -168
終止式的小節裡（4,8,12...小節） 的音不是和弦音
8 The note is the first note in a phrase and is a chord note (chord root note) 156 745
小節裡的第1個音是和弦音（第1個音）
9 The note is the first note in a phrase and is a chord note (chord 2nd note) 132 839
小節裡的第1個音是和弦音（第2個音）
10 The note is the first note in a phrase and is a chord note (chord 3rd note) 192 885
小節裡的第1個音是和弦音（第3個音）
11 The note is the last note in a phrase and is a chord note (chord root note) 135 3584
小節裡的最後一個音是和弦音（第1個音）
12 The note is the last note in a phrase and is a chord note (chord 2nd note) 149 380
小節裡的最後一個音是和弦音（第2個音）
13 The note is the last note in a phrase and is a chord note (chord 3rd note) 149 1372
小節裡的最後一個音是和弦音（第3個音）
14 The note is the last note in a phrase and is a chord note (chord 4th note) 101 1687
小節裡的最後一個音是和弦音（第4個音？？？）
15 Chord note on stress 557 441
這個音是和弦音而且是在重音上(最快八分音符來說就是1,2,3,4拍)
16 Invalid note on stress 175 -2216
重音上有不是和弦的音？？？


//////dominate the structure of each phrase, making them complete
//////and controlling the length
17 Integral phrase 146 359
？？？完整的樂句？？？
18 Phrase exceed 3 bars 296 -30
？？？

//////handle the resolution and the process of active and inactive tones.
resolutions ... 【音乐】由不谐和音转变为谐和音(解決)
19 From active tone to inactive tone 178 -691
20 Resolution from active tone to inactive tone 147 -542
21 From active tone to active tone 1115 -182
22 Resolution for chord 106 34
23 From inactive tone to inactive tone 2018 276
24 From inactive tone to active tone 475 -941


//////consider the scales and leaps in order to generate smooth and rational melodies.
scales 音階   leap  跳進
25 Process of scale (ascending) 1523 40
26 Process of scale (descending) 1980 223
連續的音（類似543 345等等）
27 Process of third leap (ascending) 1971 -33
跟前面的往上跳三度（1->3）
28 Subsequent process of third leap (ascending) 198 -307
跟後面的往上跳三度（1->3）
29 Process of third leap (descending) 239 176
30 Subsequent process of third leap (descending) 358 -55
31 Process of fourth leap (ascending) 259 -249
32 Subsequent process of fourth leap (ascending) 134 1085
33 Process of fourth leap (descending) 112 36
34 Subsequent process of fourth leap (descending) 231 81
35 Process of fifth leap (ascending) 201 634
36 Subsequent process of fifth leap (ascending) 119 99
37 Process of fifth leap (descending) 255 54
38 Subsequent process of fifth leap (descending) 104 77
39 Process of sixth leap (ascending) 78 10
40 Subsequent process of sixth leap (ascending) 247 34
41 Process of sixth leap (descending) 388 19
42 Subsequent process of sixth leap (descending) 531 7

Adaptive Partition Evolutionary Genetic Algorithm
1  2 3 4  5  6  7 8
60 0 0 65 66 60 0 0
每個音符都是連起來的
0代表這個時間點沒有新的音(就是上一個音延續下來)

1.Initial
2.PSO更新：第1個點對第1個點去更新，如果best沒有那個點就只有random的移動
3.GA交配：一定機率內，隨便選一個位置，再選兩個個體進行交配
4.GA突變：一定機率內，隨便選一個點上他變成(重新指定位置，或是掛掉，原本掛掉的點也可以被選到)
5.Fitness
6.更新GBest, PBest

用Form1-1跟Form2
*/
